<template>
    <h3>公告列表</h3>
    <div>
        <input type="button" value="添加公告" @click="add">
        <div>
            关键字:<input type="text" v-model="a.title" />
            公告类型:<select v-model="a.telltype">
                <option value="">请选择</option>
                <option value="服务协议">服务协议</option>
                <option value="雇佣协议">雇佣协议</option>
                <option value="政策协议">政策协议</option>
            </select>
            <input type="button" value="查询" @click="show">
            <input type="button" value="导出" @click="exports">
        </div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>Id</td>
                    <td>标题</td>
                    <td>分类</td>
                    <td>图片</td>
                    <td>状态</td>
                    <td>发布时间</td>
                </tr>
                <tr v-for="item in data.list">
                    <td>{{ item.Id }}</td>
                    <td>{{ item.Title }}</td>
                    <td>{{ item.TellType }}</td>
                    <td><img :src="item.Photo" width="200"></td>
                    <td>{{ item.State == 1 ? "显示" : "隐藏" }}</td>
                    <td>{{ moment(item.CreateTime).format("YYYY-MM-DD HH:mm:ss") }}</td>
                </tr>
            </tbody>
        </table>




    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted, shallowReactive } from 'vue'
import axios from 'axios';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();
const add: any = () => {
    router.push("/telladd");
}

onMounted(()=>{
    show();
})

let a: any = reactive({
    title: '',
    telltype: ''
})

let data: any = reactive({
    list: []
})

const exports:any=()=>{
    location.href=`http://localhost:5084/api/ALL/Export?title=${a.title}&telltype=${a.telltype}`
}

const show:any=()=>{
    axios({
        url:'/api/ALL/ShowTell',
        method:'get',
        params:a
    })
    .then((res)=>{
        data.list=res.data
    })
}








</script>

<style scoped></style>